import UI_MainMediator from "./ui/UI_MainMediator";
import { LoadUIPack } from "../LTGame/UI/LoadUIPack";
import FGuiEx from "../LTGame/UI/FGuiEx";
import LTRes from "../LTGame/Res/LTRes";
import UI_ChooseClientMediator from "./ui/UI_ChooseClientMediator";
import MainBinder from "../ui/Main/MainBinder";
import { DebuggerManager } from "./debugger/DebuggerManager";
import { EventCenter } from "../LTGame/Event/EventCenter";
import { LTInput } from "../LTGame/Event/LTInput";

export class ClientMain {

    constructor() {
        this._Start();
    }

    private async _Start() {
        /*
        let debugInject = new ltg.DebugInject();
        debugInject.Init('ws://127.0.0.1:8787');
        */

        EventCenter.CreateInstance();
        LTInput.CreateInstance();

        DebuggerManager.CreateInstance();

        FGuiEx.Init();

        let loadUrls: string[] = [];
        let needLoadUIPacks: LoadUIPack[] = [
            new LoadUIPack("res/fgui/Main"),
        ];
        for (let pack of needLoadUIPacks) {
            pack.PushUrl(loadUrls);
        }
        await LTRes.Load2dAsync(loadUrls);
        for (let pack of needLoadUIPacks) {
            pack.AddPackage();
        }

        MainBinder.bindAll();

        UI_MainMediator.instance.Show();

        UI_ChooseClientMediator.instance.Show();
    }

}